<template>
  <div class="photoinfo-container">
    <h4>{{ photoinfo.title }}</h4>
    <p class="subtitle">
      <span>发表时间：{{ photoinfo.add_time | dateFromt }}</span>
      <span>点击：{{ photoinfo.click }}次</span>
    </p>
    <hr />
    <!-- 缩略图 -->
    <div class="thum">
      <vue-preview :slides="list" @close="handleClose"></vue-preview>
    </div>

    <div class="content" v-html="photoinfo.content"></div>

    <!-- 评论 -->
    <cmt-box :id="id"></cmt-box>
  </div>
</template>
<script>
import comment from "../common/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      photoinfo: {},
      list: []
    };
  },
  components: {
    "cmt-box": comment
  },
  created() {
    this.getPhotoInfo();
    this.getThumImages();
  },
  methods: {
    getPhotoInfo() {
      this.$http.get("api/getimageinfo/" + this.id).then(result => {
        if (result.data.status == 0) {
          this.photoinfo = result.data.message[0];
        }
      });
    },
    getThumImages() {
      this.$http.get("api/getthumimages/" + this.id).then(result => {
        if (result.data.status == 0) {
          result.data.message.forEach(item => {
            (item.w = 1200), (item.h = 1200), (item.msrc = item.src);
          });
          this.list = result.data.message;
        }
      });
    },
    handleClose() {
      console.log("close event");
    }
  }
};
</script>
<style lang="scss" scope>
.photoinfo-container {
  padding: 0 3px;
  h4 {
    font-size: 15px;
    text-align: center;
    color: #22f;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .content {
    font-size: 13px;
    line-height: 30px;
  }
  .thum {
    div {
      width: 100%;
      figure {
        width: 100px;
        margin: 10px;
        display: inline-block;
      }
      img {
        width: 100%;
      }
    }
  }
}
</style>